# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
fastlane_require "active_support"
fastlane_require "active_support/core_ext"

default_platform(:android)

platform :android do
  changelog = sh "git log --pretty=format:%s --oneline --ancestry-path HEAD~1..HEAD"
  changelogs_dir = "metadata/android/en-US/changelogs"
  changelog_file = changelogs_dir + "/" + "default.txt"
  
  sh("mkdir", "-p", changelogs_dir)
  File.open(changelog_file, 'w') do |file|
    file.write changelog.truncate(500)
  end

  desc "Deploy a new version to the Google Play"
  lane :production do
    upload_to_play_store(aab: "./build/app/outputs/bundle/release/app-release.aab", skip_upload_screenshots: true, skip_upload_images: true)
  end
end
